package com.example.iterator;

/**
 * Created by Risky57 on 2017/4/28.
 */

public class Teachers implements Iterable {
    private String [] names = new String[]{"没", "洗", "完", "出", "来", "玩"};

    @Override
    public Iterator iterator () {
        return new ArrayIterator();
    }

    private class ArrayIterator implements Iterator<String>{
        private int index;
        @Override
        public boolean hasNext () {
            if (index < names.length) return true;
            return false;
        }

        @Override
        public String next () {
            if (hasNext()){
                return names[index++];
            }
            return null;
        }
    }

}
